package com.cwvs.utils;

import org.apache.commons.lang.StringUtils;
public class OracleSqlUtil {
	public String getOraclePageSQL(String queryString, Pages page) {
		if (StringUtils.isEmpty(queryString)) {
			return null;
		}
		if (page.getCurrentPage() <= 1) {
			page.setCurrentPage(1);
		}
		page.setBeginRow((page.getCurrentPage() - 1) * page.getPageSize());

		int endIndex = page.getBeginRow() + page.getPageSize();
		String endSql = "select * from (select oraclePageSQL.*,ROWNUM as currentRow from ("
				+ queryString
				+ ") oraclePageSQL where rownum <="
				+ endIndex
				+ ") where currentRow>" + page.getBeginRow();
		return endSql;
	}
}
